var getLoginData = function(data, callback) {
    $.ajax({
        type: 'post',
        url: '/user/login',
        data: data,
        dataType: 'json',
        success: function(data) {
            callback && callback(data);
            console.log(data)
        }
    });
}

$('#btn_login').click(function() {
    var params = {
        username: $.trim($('[name="name"]').val()),
        password: $.trim($('[name="pass"]').val())
    };
    console.log(params);
    if (!params.username || !params.password) {
        alert('请输入用户名或密码');
        return false;
    }
    getLoginData(params, function(data) {
        if (data.success) {
            // var returnUrl = LeTao.USER_URL;
            // if (location.search) {
            //     returnUrl = location.search.replace('?returnUrl=', '');
            // }
            setCookie("username", params.username, 0.5);
            location.href = "shop.html";
        } else if (data.error) {
            //  mui.toast(data.message);
        }
        $('.btn_login').html('登录成功');
    });
});